/*
 * Created by JFormDesigner on Tue Jun 18 21:23:56 CST 2024
 */

package 作业;

import javax.swing.*;
import javax.swing.GroupLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.sql.SQLException;
import java.util.Vector;

/**
 * @author RYTHON
 */
public class AdEditTicket extends JFrame {
    public static void main(String[] args) throws SQLException {
        new AdEditTicket().setVisible(true);
    }
    public AdEditTicket() throws SQLException {
        initComponents();
    }

    private void initComponents() throws SQLException {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents  @formatter:off
        scrollPane1 = new JScrollPane();
        Vector title=new Vector();
        setTitle("车票管理");
        //add添加的是地址，使用clear会导致所有数据一样，因此需要每次重新实例化一个对象
        title.add("始发站点");
        title.add("到达站点");
        title.add("费用");
        title.add("时间");
        title.add("余票");
        title.add("编号");
        Vector text=Getdb.op.GetAllTicket();
        table1 = new JTable(text,title);

        table1.addMouseListener(new MouseListener() {
            @Override
            public void mouseClicked(MouseEvent e) {
                int row=table1.getSelectedRow();
                dispose();
                new AdSubEd((String)table1.getValueAt(row,0),(String)table1.getValueAt(row,1),(String)table1.getValueAt(row,2),(String)table1.getValueAt(row,3),(String)table1.getValueAt(row,4),(String)table1.getValueAt(row,5)).setVisible(true);
            }

            @Override
            public void mousePressed(MouseEvent e) {

            }

            @Override
            public void mouseReleased(MouseEvent e) {

            }

            @Override
            public void mouseEntered(MouseEvent e) {

            }

            @Override
            public void mouseExited(MouseEvent e) {

            }
        });
        //======== this ========
        var contentPane = getContentPane();

        //======== scrollPane1 ========
        {
            scrollPane1.setViewportView(table1);
        }

        GroupLayout contentPaneLayout = new GroupLayout(contentPane);
        contentPane.setLayout(contentPaneLayout);
        contentPaneLayout.setHorizontalGroup(
            contentPaneLayout.createParallelGroup()
                .addGroup(contentPaneLayout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(scrollPane1, GroupLayout.DEFAULT_SIZE, 731, Short.MAX_VALUE)
                    .addContainerGap())
        );
        contentPaneLayout.setVerticalGroup(
            contentPaneLayout.createParallelGroup()
                .addGroup(contentPaneLayout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(scrollPane1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pack();
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents  @formatter:on
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables  @formatter:off
    private JScrollPane scrollPane1;
    private JTable table1;
    // JFormDesigner - End of variables declaration  //GEN-END:variables  @formatter:on
}
